{% extends "base.html" %}
{% block title %}
Brisanje izpitnega roka
{% endblock %}

{% block content %}


{% if only_search %}

<script type="text/javascript" src="{{ MEDIA_URL }}js/search.js"></script>
<script type="text/javascript">

$(document).ready(function(){    
    search_setcb('professor',function(professor){
      url = '/exams/delete_exam/'+professor.pk+'/';
      document.location = url;
    });
    
});
</script>
{% include "snippets/professor/search.htm" %}

{% else %}
<script type="text/javascript">
$(document).ready(function(){
    
   $("#id_exam").change(function(){    
    selected_value = $('#id_exam option:selected').val();
    if (selected_value != undefined && selected_value != "") {
      document.location="/exams/delete_exam/{{ professor.pk }}/"+selected_value+"/";
    }
   });
   {% if exam.num_students > 0%}
    $("#delete_submit").submit(function(){
      var answer = confirm("Prijave na izpit že obstajajo. Vseeno zbrišen rok?")
      return answer;
    });
   {% endif %}

});
</script>
<p>
  <b>Izbrani profesor: </b> {{ professor }}<br />
</p><br />
{% if info %}
  <div class="info_msg">Izpitni rok je bil izbrisan.</div>
{% endif %}
<form method="post">
{% csrf_token %}
	{{ form.as_p }}
</form>
{% endif %}

{% if exam %}
<form id="delete_submit" method="post">
{% csrf_token %}
  <table class="list" width="90%">
    <tr>
      <th width="10%">Datum</th>
      <th>Predmet</th>
      <th width="15%">Število prijav</th>
      <th width="35%">&nbsp;</th>
    </tr>
    <tr>
      <td>{{ exam.date }}</td>
      <td>{{ exam.subject.subject.name }}</td>
      <td>{{ exam.num_students }}</td>
      <td>{% if not exam.has_results_or_grades %}<input type="submit" value="Izbriši" />{% else %}Brisanje roka ni mogoče, ker so bili podatki o uspehih že vnešeni.{% endif %}</td>
    </tr>
  </table>
</form>

{% endif %}


{% endblock %}>